var tigerMyClient = {
	load : function () {
		Ext.QuickTips.init();  
	 	
		var store = new Ext.data.JsonStore ({
			url : "/ad/sys/com/control/UserService.php?action=queryTargetAccountMember",
			root : "row",
			remoteSort: false,
			totalProperty: 'count',
			fields : ["account", "name", "status", "createTime","isPay","isNewAd"]
		});
		 
		var grid =new Ext.grid.GridPanel({
			renderTo : "grid",
			store :  store,
			columns : [ 
				new Ext.grid.RowNumberer(),
				{header : "帳號" ,dataIndex : "account", width :40,sortable : true,renderer:function (value, p, record){
					return String.format("<a href='tigerAccount.php?editType=1&account={0}'>{0}</a>", value);
				}},
				{header : "姓名", dataIndex : "name",width :40, sortable : true},
				{header : "狀態", dataIndex : "status",width :10,sortable : true,renderer:function (value, p, record){
					return value ==1 ? "啟用" : "停用";
				}},
				{header : "建立時間", dataIndex : "createTime",width :30 , sortable : true ,
					renderer:function (value , p, record){
						return  value.toDateString();
					}
				},
				{header : "有未收費", dataIndex : "isPay" , width : 15, sortable : true, renderer : 
					function (value, p, record){
						return value == 0 ? "無": "有";
					}
				},
				{header : "新申請廣告", dataIndex : "isNewAd",width :15, sortable : true, 
					renderer : function (value, p , record){
						return value ==0 ? "無": "有";
					}
				},
				{   header : '', width : 20,
		            renderer : function (value, p, record) {
            	    	return String.format('<b><a href="javascript:tigerMyClient.edit(\'{0}\',\'{1}\')">編輯</a></b>', record.data.account, record.data.name);
		            }  
		        }
			],
			height: 325,
		    autoWidth: true,
			loadMask : true,
			viewConfig : {
				forceFit : true
			},
			/* 
			tbar : new Ext.PagingToolbar({
				pageSize :10,
				store : store,
				displayInfo : true,
				displayMsg : "顯示第 {0} 筆到 {1} 筆紀錄,共 {2} 筆紀錄",
				emptyMsg : "沒有紀錄" 
			}),*/
			bbar : new Ext.PagingToolbar({
				pageSize :10,
				store : store,
				displayInfo : true,
				displayMsg : "顯示第 {0} 筆到 {1} 筆紀錄,共 {2} 筆紀錄",
				emptyMsg : "沒有紀錄" 
			})
			 
		});
		store.load({
			params:{
				start:0,
				limit:10
			}
		});
		
		
	
	}, 
	
	edit : function  (account, name) {
		 window.location = "/ad/html/frontoffice/tigerManageAdCustomer.php?customerAccount="+account+"&customerName="+encodeURI(name)
	}
	
	
}


Ext.onReady(function (){
	tigerMyClient.load();	
});